package library.and.xps.com.step.view.fragment;

import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;

import library.and.xps.com.step.R;
import library.and.xps.com.step.view.base.BaseFragment;

public class CreateTeamPassFragment extends BaseFragment {
    EditText et_pass = null;
    CheckBox cb_no_pass;

    @Override
    protected int getRes() {
        return R.layout.fragment_create_team_pass;
    }

    @Override
    protected void init(View view) {
        et_pass = r2v(view, R.id.et_pass);
        cb_no_pass = r2v(view, R.id.cb_no_pass);
        cb_no_pass.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    et_pass.setText("");
                    et_pass.setHint("不需要密码");
                    et_pass.setEnabled(false);
                } else {
                    et_pass.setHint("输入团队密码");
                    et_pass.setEnabled(true);
                }
            }
        });
    }

    @Override
    protected void setData(View view) {

    }

    public void hide() {
        FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.hide(this);
        fragmentTransaction.commit();
    }

    public String getPassword() {
        String pass = et_pass.getText().toString();
        if (TextUtils.isEmpty(pass))
            return null;
        return pass;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.et_pass:

                break;
            case R.id.cb_no_pass:
                break;
        }
    }

}
